/*
* =====================================================================================
*
*       Filename:  except.c
*
*    Description:  
*
*        Version:  1.0
*        Created:  2010年09月19日 00时01分43秒
*       Revision:  none
*       Compiler:  gcc
*
*         Author:  YOUR NAME (), 
*        Company:  
*
* =====================================================================================
*/
#include "me/except.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

except_frame_t *except_stack = NULL;


void 
except_raise(except_t *e, const char *file, unsigned int line)
{
	assert(e);
	except_frame_t *p = except_stack;
	if (!p) {
		fprintf(stderr, "  exception: [ %p | %s ]"
			"\n\t@[ %s/ %d ]: \"%s\""
			"\n\taborting ...\n",  e, e->name, file, line, e->description);
		fflush(stderr);
		abort();
	} else {
		except_stack = p->prev_frame;
		p->exception = e;
		p->file = file;
		p->line = line;
		longjmp(p->env, Except_raised);
	}

	assert(0);
}

